package com.kevin.v2.spring.formework.aop.aspect;

import com.kevin.v2.spring.formework.aop.intercept.KvMethodInterceptor;
import com.kevin.v2.spring.formework.aop.intercept.KvMethodInvocation;

import java.lang.reflect.Method;

/**
 * 前置通知处理类
 */
public class KvMethodBeforeAdvice extends  KvAbstractAspectAdvice implements KvMethodInterceptor {

   private KvJoinPoint kvJoinPoint;


   public KvMethodBeforeAdvice (Method aspectMethod, Object aspectTarget) {
      super(aspectMethod, aspectTarget);
   }

   private  void  before( Method aspectMethod,Object args, Object aspectTarget){
      super.invokeAdviceMethod(kvJoinPoint, null, null);
   }

   @Override
   public Object invoke (KvMethodInvocation methodInvocation) throws Throwable {
      kvJoinPoint = methodInvocation;
      before(methodInvocation.getMethod(),methodInvocation.getArgs(),methodInvocation.getThis());
      return  methodInvocation.proceed();
   }
}
